/**
 *  发出请求，返回promise
 * @param {string} url 请求地址
 * @param {number} maxCount 最大重试次数
 */
async function request(url, maxCount = 5) {
    return await fetch(url).catch((error) =>
      maxCount <= 0 ? Promise.reject(error) : request(url, maxCount - 1)
    );
  }
  
request("http://129.211.31.58:8080/api/board/loadBoard", 6)
.then(async (pending) => {
    const result = await pending.json();
    console.log(result);
})
.catch((err) => {
    console.log("网络异常");
});


async function retryableFetch(url, options = {}, retries = 3, delay = 1000) {
    try {
      const response = await fetch(url, options);
      if (!response.ok) {
        throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
      }
      return response.json();
    } catch (error) {
      if (retries > 0) {
        await new Promise((resolve) => setTimeout(resolve, delay));
        return retryableFetch(url, options, retries - 1, delay);
      }
      throw error;
    }
  }
